import 'package:flutter/material.dart';

class TabBarController extends StatefulWidget {
  final Map data;
  TabBarController(this.data, {Key key}) : super(key: key);

  @override
  _TabBarControllerState createState() => _TabBarControllerState(data: this.data);
}

class _TabBarControllerState extends State<TabBarController> with SingleTickerProviderStateMixin {
  
  final data;
  _TabBarControllerState({this.data});

  TabController _tabController;
  @override
  void initState() { 
    super.initState();
    
    _tabController = new TabController(
      vsync: this,
      length: this.data['tabs'].length
    );
  }
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: Text('${this.data['title']}'),
        bottom: TabBar(
          controller: this._tabController,
          tabs: this.data['tabs']
        ),
      ),
      body: TabBarView(
        controller: this._tabController,
        children: this.data['body'],
      ),
    );
  }
}